package com.zxy.supplier_system.server.controller

import com.zxy.supplier_system.server.entity.Notification
import com.zxy.supplier_system.server.service.NotificationService
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
class NotificationController(
    private val notificationService: NotificationService
) {

    @RequestMapping("notifications")
    fun getNotifications(): List<NotificationResponse> {
        return notificationService.getNotifications().map {
            NotificationResponse(it.id,it.type,it.data)
        }
    }

    data class NotificationResponse(
        val id:Int,
        val type:Notification.Type,
        val data:Any?,
    )

}